package com.czk.netty.web;

import com.czk.netty.server.NettyServer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/4/21 11:49
 */
@RestController
@RequestMapping("/netty")
public class NettyController {
    @Resource
    private NettyServer nettyServer;

    /**
     * 获取服务器ip
     *
     * @return
     */
    @GetMapping("/address")
    public String localAddress() {
        return "nettyServer Address" + nettyServer.getChannel().localAddress();
    }

    @GetMapping("/open")
    public String isOpen() {
        return "is open" + nettyServer.getChannel().isOpen();
    }
}
